#测试详情页
from common.Utils import  BlogDriver
from selenium.webdriver.common.by import By
class BlogDetail:
    url = ""
    driver = ""
    def __init__(self):
        self.url="http://8.137.19.140:9090/blog_detail.html?blogId=25591"
        self.driver=BlogDriver.driver
        self.driver.get(self.url)

    def check_row(self):
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > img")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > span")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > a:nth-child(4)")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > a:nth-child(5)")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > a:nth-child(6)")

    #检查页面,因为该账号是公用的，因此我们需要测试自己上传的博客以及别人登陆此账号上传的博客#以2025-03-16 22:11这篇为例
    def check(self):
        BlogDriver.getScreenShot()
        # self.check_row()

        #对于博客详情页的昵称是否为本人
        txt=self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > h3").text
        if txt=="lisi":
            print("检查其他人登陆此用户博客详情页中昵称正确")
        else:
            print("检查其他人登陆此用户博客详情页中昵称不正确")

        #上面测试的是其他人写的博客，测试完成后返回上一级，找到自己的博客
        self.driver.back()
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1535) > a").click()

        #进入自己的博客后检查昵称是否是自己
        text=self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > h3").text
        # assert text=="lisi"

        #检查标题，检查时间，检查内容，检查编辑按钮，检查删除按钮
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div > div.title")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div > div.date")
        self.driver.find_element(By.CSS_SELECTOR,"#h2-u5728u8FD9u91CCu5199u4E0Bu4E00u7BC7u535Au5BA2")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div > div.operating > button:nth-child(1)")
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div > div.operating > button:nth-child(2)")


        #返回上一级，然后执行博客编辑页测试
        self.driver.back()
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > a:nth-child(5)").click()
        BlogDriver.getScreenShot()

Detail=BlogDetail()





